<?php
        include_once("clases/Conexion.php");

       $link= new Conexion("mysql5.000webhost.com","a4175171_root","mendomapa123","a4175171_menues");

       $query = "SELECT men.titulo,men.color, sm.titulo1,sm.esitem,ssm.titulo2,ssm.icono
                        FROM menu AS men
                        INNER JOIN submenu AS sm ON men.id = sm.idmenu
                        INNER JOIN subsubmenu AS ssm ON sm.id = ssm.idsubmenu " ;
        $query2 = " SELECT men.titulo, men.color, sm.titulo1,sm.esitem,sm.icono
                    FROM menu AS men
                    INNER JOIN submenu AS sm ON men.id = sm.idmenu
                    WHERE esitem = 1";

       $result =  mysql_query($query);
       $result2 =  mysql_query($query2);
       if (!$result) {
         echo "No pudo ejecutarse satisfactoriamente la consulta ($sql) " .
         "en la BD: " . mysql_error();
           exit;
        }
        if (!$result2) {
         echo "No pudo ejecutarse satisfactoriamente la consulta ($sql) " .
         "en la BD: " . mysql_error();
           exit;
        }
       while ($rowEmp = mysql_fetch_assoc($result)) {

           $data[] = $rowEmp;
       }
       while ($rowEmp2 = mysql_fetch_assoc($result2)) {

           $data2[] = $rowEmp2;
       }
       $data3 = array_merge($data, $data2);
       //echo json_encode($data3);

       $ar=fopen("../js/menues.json","w") or die("Problemas en la creacion");
        fputs($ar, json_encode($data3));
        echo 'json menu subido con exito!'
        ?>
